import request from "@/utils/request";

export function getBlogList(page = 1, limit = 10) {
    return request({
        url: "/api/blog",
        method: "get",
        params: {
            page,
            limit
        }
    });
}

export function deleteBlog(id) {
    return request({
        url: `/api/blog/${id}`, // /api/blog/{id}
        method: "delete"
    });
}

export function addBlog(data) {
    return request({
        url: `/api/blog`,
        method: "post",
        data
    });
}

// 修改文章数据
export function editBlog(blogInfo) {
    return request({
        url: `/api/blog/${blogInfo.id}`,
        method: "put",
        data: blogInfo.data,
    });
}

// 通过id获取文章数据
export function findOneBlog(id) {
    return request({
        url: `/api/blog/${id}`,
        method: 'get'
    })
}